package sala.commonmovie.mainmenu 
{
	import flash.display.MovieClip;
	import gs.TweenLite;
	import sala.events.MainMenuEvent;
	import sala.model.AlbumInfo;
	/**
	 * ...
	 * @author Sun
	 */
	public class MainMenu extends MovieClip
	{
		private var albumInfoArr:Array;
		private var albumItemArr:Array;
		
		private var activeItem: MainMenuItem;
		public function MainMenu() 
		{
			this.addEventListener(MainMenuEvent.MAIN_MENU_ITEM_CLICKED, mainMenuItemClickedHdl);
		}
		
		private function mainMenuItemClickedHdl(e:MainMenuEvent):void 
		{
			activeItem.active = false;
			activeItem = MainMenuItem(e.target);
			activeItem.active = true;
		}
		
		public function initMainMenu(aInfoArr:Array): void
		{
			while (this.numChildren)
			{
				this.removeChildAt(0);
			}
			
			albumInfoArr = aInfoArr;
			albumItemArr = [];
			var mainItem: MainMenuItem;
			var albumInfo: AlbumInfo;
			for (var i:uint = 0; i < albumInfoArr.length; i++)
			{
				mainItem = new MainMenuItem();
				albumInfo = albumInfoArr[i];
				mainItem.updateMainMenuItem(albumInfo);
				mainItem.y = i * 30
				this.addChild(mainItem);
				albumItemArr.push(mainItem);
			}
			
			if (albumItemArr.length)
			{
				activeItem = albumItemArr[0];
				activeItem.active = true;
			}
		}
		
		public function tweenIn():void
		{
			TweenLite.to(this, 2, { x:677} ); 
		}
	}

}